import time

from NanNing.common import RadarTEST
from NanNing.common import UdpClient

datHex1 = ["0103010017f78416caa0001b407e5ad403dd58c00178036440",
           "0103010017f78416caa0001b407e5ad403dd58c00178036440",
           "0103010017f78416caa001fd28c35c6407d3da740798064440",
           "0103010017f78416caa001fd28c35c6407d3da740798064440",
           "0103010017f78416caa0012d1ea45c8006d8db6408bc040040",
           "0103010017f78416caa0012d1ea45c8006d8db6408bc040040",
           "0103010017f78416caa003085ae15d0806f1a05806e2055440",
           "0103010017f78416caa003085ae15d0806f1a05806e2055440",
           "0103010017f78416caa00005423f5d98078bed4808be040040",
           "0103010017f78416caa00005423f5d98078bed4808be040040",
           "0103010017f78416caa003402ffd5e3c081778100708057c40",
           "0103010017f78416caa003402ffd5e3c081778100708057c40",
           "0103010017f78416caa000d054df5e7807c9224001bf03d840",
           "0103010017f78416caa000d054df5e7807c9224001bf03d840",
           "0103010017f78416caa000d159755f140799ae100aed05f440",
           "0103010017f78416caa000d159755f140799ae100aed05f440",
           "0103010017f78416caa0006d049b5e14073edce0052a040040",
           "0103010017f78416caa0006d049b5e14073edce0052a040040",
           "0103010017f78416caa002cc4ac660a406e9e0a408bf033040",
           "0103010017f78416caa002cc4ac660a406e9e0a408bf033040",
           "0103010017f78416caa0018f61fd64a8083505ec08b8048cc0",
           "0103010017f78416caa0018f61fd64a8083505ec08b8048cc0",
           "0103010017f78416caa0013450d460f8074de94c01a902ec40",
           "0103010017f78416caa0013450d460f8074de94c01a902ec40",
           "0103010017f78416caa0013042c86690081f6ebc00f8050440",
           "0103010017f78416caa0013042c86690081f6ebc00f8050440",
           "0103010017f78416caa0020c622068f0084f89900d3d050440",
           "0103010017f78416caa0020c622068f0084f89900d3d050440",
           "0103010017f78416caa0016262346afc079086d4000b046840",
           "0103010017f78416caa0016262346afc079086d4000b046840",
           "0103010017f78416caa000285acc6fcc065aa3c4094d03e440",
           "0103010017f78416caa000285acc6fcc065aa3c4094d03e440",
           "0103010017f78416caa0025063ed74d8095c23900c4e061c40",
           "0103010017f78416caa0025063ed74d8095c23900c4e061c40",
           "0103010017f78416caa0038e682f7bc008a3a79c065105f040",
           "0103010017f78416caa0038e682f7bc008a3a79c065105f040",
           "0103010017f78416caa003b7422a801007808354081504b440",
           "0103010017f78416caa003b7422a801007808354081504b440",
           "0103010017f78416caa002f368f3925c075d709c09a9050040",
           "0103010017f78416caa002f368f3925c075d709c09a9050040",
           "0103010017f78416caa000f804b09f28030d1ff40f03006840",
           "0103010017f78416caa000f804b09f28030d1ff40f03006840",
           "0103010017f78416caa002a75905aa3009a42b5801cf052840",
           "0103010017f78416caa002a75905aa3009a42b5801cf052840",
           "0103010017f78416caa003c23cf6ab9009181d140f0905c840",
           "0103010017f78416caa0035645a3afd406d5a6f00520050040",
           "0103010017f78416caa003c23cf6ab9009181d140f0905c840",
           "0103010017f78416caa003530c33af7c09463790052904a440",
           "0103010017f78416caa0035645a3afd406d5a6f00520050040",
           "0103010017f78416caa003530c33af7c09463790052904a440",
           "0103010017f78416caa000fe0876ce4808a35e84036f052c40",
           "0103010017f78416caa001ac2f1fd34006ef56a40a1a02ac40",
           "0103010017f78416caa000fe0876ce4808a35e84036f052c40",
           "0103010017f78416caa001b250a9d66008f44c300443048c40",
           "0103010017f78416caa000994941d7cc09284aa40149066c40",
           "0103010017f78416caa001ac2f1fd34006ef56a40a1a02ac40",
           "0103010017f78416caa0016351aad8281648a410095404b440",
           "0103010017f78416caa001b250a9d66008f44c300443048c40",
           "0103010017f78416caa000994941d7cc09284aa40149066c40",
           "0103010017f78416caa002d71073da9007cf5e400f06042840",
           "0103010017f78416caa0016351aad8281648a410095404b440",
           "0103010017f78416caa0017f035ddbfc111c59ac094f045040",
           "0103010017f78416caa0033f10a6de680743def408b905a440",
           "0103010017f78416caa002d71073da9007cf5e400f06042840",
           "0103010017f78416caa0028539a4deb80751dfb0053804b440",
           "0103010017f78416caa0017f035ddbfc111c59ac094f045040",
           "0103010017f78416caa0027417eade9407abe0180942045040",
           "0103010017f78416caa0033f10a6de680743def408b905a440",
           "0103010017f78416caa0019e2ff6e1f8094c43a80d1d057c40",
           "0103010017f78416caa0028539a4deb80751dfb0053804b440",
           "0103010017f78416caa0027417eade9407abe0180942045040",
           "0103010017f78416caa003bb18a2e2b40772edc4094a040040",
           "0103010017f78416caa0019e2ff6e1f8094c43a80d1d057c40",
           "0103010017f78416caa00369283dea3c09f64460068805cc40",
           "0103010017f78416caa003bb18a2e2b40772edc4094a040040",
           "0103010017f78416caa00369283dea3c09f64460068805cc40",
           "0103010017f78416caa00397241bfb18082746ec0737038840",
           "0103010017f78416caa00397241bfb18082746ec0737038840",
           "0103010017f78416caa001112ba7fb6c06da8d740340042840",
           "0103010017f78416caa001112ba7fb6c06da8d740340042840",
           "0103010017f78416caa0016143b5fd780843785c0f05052c40",
           "0103010017f78416caa0016143b5fd780843785c0f05052c40",
           "0103010017f78416caa001b53c12fdb80802790c081a03d840",
           "0103010017f78416caa001b53c12fdb80802790c081a03d840",
           "0103010017f78416caa003b6212b0288094444500d0d05cc40",
           "0103010017f78416caa003b6212b0288094444500d0d05cc40",
           "0103010017f78416caa003d63ef5038807cb752c0e29048c40",
           "0103010017f78416caa003d63ef5038807cb752c0e29048c40",
           "0103010017f78416caa0022f3fe20400089f681004dc053040",
           "0103010017f78416caa0022f3fe20400089f681004dc053040",
           "0103010017f78416caa002aa375a0820092864000469048c40",
           "0103010017f78416caa002aa375a0820092864000469048c40",
           "0103010017f78416caa000d31e2d114c06618dc00a1d02fc40",
           "0103010017f78416caa000d31e2d114c06618dc00a1d02fc40",
           "0103010017f78416caa0031259d4174807848fd00d3905f440",
           "0103010017f78416caa0031259d4174807848fd00d3905f440",
           "0103010017f78416caa0030153de173807ad0068096105cc40",
           "0103010017f78416caa0030153de173807ad0068096105cc40",
           "0103010017f78416caa001881c5b174c06f49954001205a440",
           "0103010017f78416caa001881c5b174c06f49954001205a440",
           "0103010017f78416caa0032c5cfa183006d596800fe7055440",
           "0103010017f78416caa0032c5cfa183006d596800fe7055440",
           "0103010017f78416caa000ed3965185406d6974c08a4054440",
           "0103010017f78416caa000ed3965185406d6974c08a4054440",
           "0103010017f78416caa003893754185806ae9648026d040040",
           "0103010017f78416caa003893754185806ae9648026d040040",
           "0103010017f78416caa001372fbc18780709944000f004b440",
           "0103010017f78416caa001372fbc18780709944000f004b440",
           "0103010017f78416caa001e939cf190c06f095f0083005a440",
           "0103010017f78416caa001e939cf190c06f095f0083005a440",
           "0103010017f78416caa0012746f51c0008b206e408b204e040",
           "0103010017f78416caa0012746f51c0008b206e408b204e040",
           "0103010017f78416caa000f72d771d04087819b4053b038840",
           "0103010017f78416caa000f72d771d04087819b4053b038840",
           "0103010017f78416caa003aa66d620280788e2c40654050440",
           "0103010017f78416caa002232e18218809ea583004de052c40",
           "0103010017f78416caa003aa66d620280788e2c40654050440",
           "0103010017f78416caa003ba22062250073f7b6400ef03f840",
           "0103010017f78416caa002232e18218809ea583004de052c40",
           "0103010017f78416caa003ba22062250073f7b6400ef03f840",
           "0103010017f78416caa000192efb23180a9d4a1406a7057c40",
           "0103010017f78416caa001ea22a02370076b7be00b91048c40",
           "0103010017f78416caa000192efb23180a9d4a1406a7057c40",
           "0103010017f78416caa000955c742620089c5e140818052c40",
           "0103010017f78416caa001ea22a02370076b7be00b91048c40",
           "0103010017f78416caa0003f0f0e264405247f700a0a01b840",
           "0103010017f78416caa000955c742620089c5e140818052c40",
           "0103010017f78416caa001af319526e00858050801be04dc40",
           "0103010017f78416caa0003f0f0e264405247f700a0a01b840",
           "0103010017f78416caa001af319526e00858050801be04dc40",
           "0103010017f78416caa0027738cf2c4c09854a240d19054c40",
           "0103010017f78416caa0006927e332a40853064c096004dc40",
           "0103010017f78416caa0027738cf2c4c09854a240d19054c40",
           "0103010017f78416caa0006927e332a40853064c096004dc40",
           "0103010017f78416caa000491d89342c07c97c400628048c40",
           "0103010017f78416caa003bc4e7b34ec0a034a380c94061c40",
           "0103010017f78416caa000491d89342c07c97c400628048c40",
           "0103010017f78416caa003bc4e7b34ec0a034a380c94061c40",
           "0103010017f78416caa001ee57f8371c09f5492c016605cc40",
           "0103010017f78416caa0002d1ebb370807b77bb8026b03d840",
           "0103010017f78416caa001ee57f8371c09f5492c016605cc40",
           "0103010017f78416caa0002d1ebb370807b77bb8026b03d840"]
sector = "010302000cf4010102907392000c"
north = "010302000bd40101011fa4000c"

if __name__ == '__main__':
    with UdpClient() as client:
        tag = 0
        while True:
            print(f"-------------------------------------------------------------------------\n"
                  f"sending message {tag + 1}")
            client.set_data('0303300046ffff0216581770008085af7b6d046405046003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5')
            client.get_data_type()
            client.connect(RadarTEST.HOST, RadarTEST.PORT2)
            client.main_send(is_print_log=True, is_send_sector=True, is_send_north=True)

            # print(f"发送32次扇区数据")
            # k = 1  # 扇区开始的计数器
            # while k < 33:
            #     time.sleep(0.125)
            #     client.set_data(sector)
            #     client.send()
            #
            #     k += 1
            #
            # print(f"发送1次正北数据: {tag}")
            # client.set_data(north)
            # client.send()

            time.sleep(4)
            tag += 1
            if tag >= len(datHex1):
                tag = 0
